<%@ page import="org.xilin.User" %>

<g:setProvider library="jquery"/>

<x:message message="${flash.message}"/>

<div class="bar">
  <span class="left">User&nbsp;&nbsp;</span>
  <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
    <span class="btn right">
      <a class="create" href="javascript:void(0)" title="Add User" rel="${request.contextPath}/user/adminCreate">Add User</a>
    </span>
  </g:if>
</div>

<x:pager/>
<table id="userTable" class="tablesorter">
    <thead>
        <tr>
            <th/>
            <th>${message(code: 'user.username.label', default: 'Login Name')}</th>
            <th>${message(code: 'user.email.label', default: 'Email')}</th>
            <th>${message(code: 'user.emailShow.label', default: 'Show Email')}</th>
            <th>${message(code: 'user.enabled.label', default: 'User Enabled')}</th>
            <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
              <th class="edit">Edit</th>
            </g:if>
        </tr>
    </thead>
    <tbody>
    <g:each in="${userInstanceList}" status="i" var="userInstance">
        <tr>
            <td>${i+1}</td>
            <td>${userInstance.username}</td>
            <td>${userInstance.email}</td>
            <td>${userInstance.emailShow}</td>
            <td>${userInstance.enabled}</td>
            <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
              <td class="edit"><a href="#" title="Edit User Data" rel="${request.contextPath}/user/adminCreate/${userInstance.id}"><span class="ui-icon ui-icon-pencil"/></a></td>
            </g:if>
        </tr>
    </g:each>
    </tbody>
</table>

<script type="text/javascript">
  $(function(){
      setupAdminList({controller:'user', action:'adminList'});
  });
</script>